<!DOCTYPE html>
<html>
<head>
<mata charset="UTF-8">
    <title>登陆成功</title>
</head>

<style type="text/css">
	.pg_header{
            position: fixed;
            height: 48px;
            top: 0;
            left: 0;
            right: 0;
            background-color: #2459a2; 
            line-height: 48px;
        }
        .pg_header .logo{
            margin: 0 auto;
            float: left;
            width: 200px;
            text-align: center;
            line-height: 48px;
            font-size: 28px;
            color: white;
        }
        .pg_dl{
            left: 400px;
            display: inline-block;
            padding: 0 40px;
            color: white;
        }
        .pg_header .pg_dl:hover{
            background-color: #2459fb;
            cursor: pointer;
        }
        .pg_logout {
            float: right;
            margin-right: 20px;
            display: inline-block;
            padding: 0 40px;
            color: white;
        }
        .pg_header .pg_logout:hover{
            cursor: pointer;
            background-color: #2459fb;
        }
        .table {
            margin-top: 200px;
            margin-left: 500px;
            table-layout: fixed;
        }
</style>

<body>
	<div class = "pg_header">
        <a class = "logo">登陆</a>
        <a class="pg_dl" id="username" />
        <a class="pg_logout" onclick="logout()">注销</a>    
    </div>
    <div class="table">
    <table border="1">
        <tr>
            <td><font color="black">用户名</font></td>
            <td><font id="tr_username" color="black"></font></td>
        </tr>
        <tr>
            <td><font color="black">邮箱</font></td>
            <td><font id="email" color="black"></font></td>
        </tr>
        <tr>
            <td><font color="black">注册时间</font></td>
            <td><font id="register_time" color="black"></font></td>
        </tr>
        <tr>
            <td><font color="black">上次登录时间</font></td>
            <td><font id="login_time" color="black"></font></td>
        </tr>
    </div>
    </table>
</body>

<script type="text/javascript">

    // 给username赋值
	var storage = window.localStorage;
    var password = storage["token"]; 
    if (password.length != 0) {
        var username = storage["username"];
        var aName = document.getElementById('username');
        aName.text = username;

        var usernameId = document.getElementById('tr_username');
        usernameId.innerHTML = username;

        var email = storage["email"];
        var emailId = document.getElementById('email');
        emailId.innerHTML = email;

        var registerTime = storage["registerTime"]; 
        var registerTimeId = document.getElementById('register_time');
        registerTimeId.innerHTML = registerTime;
    
        var loginTime = storage["loginTime"];
        var loginTimeId = document.getElementById('login_time');
    
    // 注销登陆
    function logout() {
        var date = new Date();
        var currentTime = date.toLocaleString();
        storage["loginTime"] = currentTime;
        if (password != "") {
            storage["token"] = "";
        }

        window.close();
    }

</script>    